/*
 * @lc app=leetcode.cn id=500 lang=typescript
 *
 * [500] 键盘行
 */

// @lc code=start
function findWords(words: string[]): string[] {
    return words.filter((i) => {
        let line = -1;
        return i.split("").every((single) => {
            let itLine = singleToLineNumber(single);
            if (line === -1) {
                line = itLine;
                return true;
            } else if (itLine === line) {
                return true;
            }
            console.log(single, line, itLine);
            return false;
        });
    });
}
let row = ["qwertyuiop", "asdfghjkl", "zxcvbnm"];
const singleToLineNumber = (s: string) => {
    s = s.toLowerCase();
    return row.findIndex((i) => {
        return i.includes(s);
    });
};
// @lc code=end
